package framework.command;

import framework.account.IAccount;
import framework.account.IEntry;
import framework.account.Transaction;

public class DebtCommand implements ICommand {
    private IAccount account;
    private float amount;
    public static final String type = "debt";

    public DebtCommand(IAccount acc, float amount) {
        this.account = acc;
        this.amount = amount;
    }

    public void execute() {
        if (account.processTransaction(-amount)) {
            IEntry tr = new Transaction(type, amount, IEntry.STATUS.SUCCESSFUL);
            account.addTransaction(tr);
        } else {
            IEntry tr = new Transaction(type, amount, IEntry.STATUS.FAILED);
            account.addTransaction(tr);
        }
    }

    @Override
    public void execute(IFunctor functor) {
        throw new UnsupportedOperationException();
    }
}
